<?php

namespace app\api\library;

use EasyWeChat\Factory;

class WeChat
{
    protected $app = null;
    protected $config = [];

    public function __construct()
    {
        $this->config = [
            'app_id' => 'wx9052d6997ec81f0f',
            'secret' => '783d086aa4def05f723e5e8a2b4999c3',
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
            'log' => [
                'level' => 'debug',
                'file'  =>  ROOT_PATH . '/public/logs/wechat.log'
            ]
        ];

        $this->app = Factory::officialAccount($this->config);
    }

    // 返回实例
    public function getApp()
    {
        return $this->app;
    }

    public function getOauth()
    {
        return $this->app->oauth;
    }

    public function getUser()
    {
        return $this->app->user;
    }

}